package edu.ifce;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		Aviao aviao = new Aviao();
		
		do{
			Passageiro p = new Passageiro();
			
			System.out.println("\n\n\n#############################");
			System.out.println("####  Reserva de Assento #### ");
			System.out.println("#############################");
			System.out.println("Nome do Passageiro: ");
			p.setNome(input.nextLine());
						
			makeReservation(aviao, p);
			
		}while(true);
	}

	private static void makeReservation(Aviao aviao, Passageiro p) {
		Assento assentos[] = aviao.getAssentos();
		String name = "teste";
      boolean alive = true;
		
		for (int i = 0; i < assentos.length && alive; i++) {
			if(assentos[i].getPassageiro() == null){
				assentos[i].setPassageiro(p);
				printTicket(p, i+1);
				alive = false;
			}
		}
		
	}

	private static void printTicket(Passageiro p, int numAssento) {
		
		System.out.println("\n\n\n#############################");
		System.out.println("####  Ticket de Reserva #### ");
		System.out.println("#############################");
		System.out.println("#############################");
		System.out.println(String.format("Nome %s", p.getNome()));
		System.out.println(String.format("Assento: %d", numAssento));
		System.out.println("#############################\n");
		
		
	}
}
